package com.sparrow.manage.comment;

import com.sparrow.manage.common.entity.StandardEntity;
import org.hibernate.annotations.GenericGenerator;

import javax.persistence.*;
import java.util.Date;

/**
 * 评论
 */
@Entity
@Table(name = "tb_comment")
public class Comment implements StandardEntity<String> {

    public enum CommentType{
        NET_WORD("网站留言", 0);

        private final String name;
        private final int code;

        CommentType(String name, int code){
            this.name = name;
            this.code = code;
        }

        public String getName() {
            return name;
        }

        public int getCode() {
            return code;
        }
    }

    @Id
    @Column(name = "ID_", length = 36)
    @GeneratedValue(generator = "uuid")
    @GenericGenerator(name = "uuid", strategy = "uuid")
    private String id;

    @Column(name = "visitor_link", length = 120)
    private String visitorLink;    // 访客连接 : 即邮箱, QQ号, 电话等联系方式

    @Column(name = "visitor_from", length = 50)
    private String visitorFrom;     // 访客来源 : 腾讯, 新浪等

    @Column(name = "visitor_name", length = 100)
    private String visitorName;     // 访客名称 : 网名等

    @Column(name = "type_", length = 1)
    private Integer type;   // 评论类型: 文章评论, 网站留言等

    @Column(name = "article_id", length = 36)
    private String articleId;   // 文章id, 如果是文章评论则存在该字段

    @Column(name = "content", columnDefinition = "Text")
    private String content; // 评论内容

    @Column(name = "create_user", length = 36, updatable = false)
    private String createUser;

    @Column(name = "create_time", updatable = false)
    private Date createTime;

    @Column(name = "update_user", length = 36)
    private String updateUser;

    @Column(name = "update_time")
    private Date updateTime;

    @Override
    public String getCreateUser() {
        return createUser;
    }

    @Override
    public void setCreateUser(String createUser) {
        this.createUser = createUser;
    }

    @Override
    public Date getCreateTime() {
        return createTime;
    }

    @Override
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    @Override
    public String getUpdateUser() {
        return updateUser;
    }

    @Override
    public void setUpdateUser(String updateUser) {
        this.updateUser = updateUser;
    }

    @Override
    public Date getUpdateTime() {
        return updateTime;
    }

    @Override
    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getVisitorLink() {
        return visitorLink;
    }

    public void setVisitorLink(String visitorLink) {
        this.visitorLink = visitorLink;
    }

    public String getVisitorFrom() {
        return visitorFrom;
    }

    public void setVisitorFrom(String visitorFrom) {
        this.visitorFrom = visitorFrom;
    }

    public String getVisitorName() {
        return visitorName;
    }

    public void setVisitorName(String visitorName) {
        this.visitorName = visitorName;
    }

    public Integer getType() {
        return type;
    }

    public void setType(Integer type) {
        this.type = type;
    }

    public String getArticleId() {
        return articleId;
    }

    public void setArticleId(String articleId) {
        this.articleId = articleId;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }
}
